package org.reenscape.model;
import org.reenscape.updater.*;
public class Follow {


					public static void UpdateFollow(PacketParser p3, PacketParser p4){
						if(p4 == null){
							p3.FollowingID = -1;
							p3.faceNPC(65535);
							return;
						}
						
						int x1 = p3.absX;	int y1 = p3.absY;
						int x2 = p4.absX;	int y2 = p4.absY;
						int x = p3.currentX; int y = p3.currentY;
						int x_ = p4.currentX; int y_ = p4.currentY;
						
						int yax = y2 - y1;
						int xax = x2 - x1;
						int x3 = x1 - 1;
						int y3 = y1 - 1;

						String r = ",";
						
						/**
						XAX:
						-1 = WEST
						0 = SAME
						1 = EAST
							
						YAX:
						-1 = SOUTH
						0 = SAME
						1 = NORTH
						*/
						
						if(xax == 0 && yax == 1){ //North
							x = x;
							y++;
						}
						else if(xax == 0 && yax == -1){ //South
							x = x;
							y--;
						}
						else if(xax == -1 && yax == 0){ //West
							y = y;
							x--;
						}
						else if(xax == 1 && yax == 0){ // East
							y = y;
							x++;
						} 
						else if(xax == 0 && yax == 0){ // Same
							x--;
							y=y;
						}
						else {
							//System.out.println(xax+r+yax);
						}
						
						p3.resetWalkingQueue();
						p3.faceNPC(p3.FollowingID);
						p3.addToWalkingQueue(x, y);
					}
}